docs: sync dialect tabs across pages#672
Open
binit2-1 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds client-side shared state so “dialect” tabs (e.g., SQLite/MySQL/PostgreSQL) stay in sync across tab groups on the same docs page, and reflects the selected dialect in the URL query string for deep-linking.
Changes:
- Introduced
setupSyncedTabs()insrc/utils-client.tsto normalize dialect labels, sync matching tab groups, and write?dialect=...to the URL. - Updated
Tabs.astroandCodeTabs.astroto provide stabledata-tab-labelvalues and delegate tab behavior to the shared helper. - Ensured non-dialect tab groups still behave locally (only recognized dialect labels participate in syncing).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/utils-client.ts | Adds dialect normalization, tab activation helpers, and URL query param syncing via setupSyncedTabs(). |
| src/mdx/Tabs.astro | Adds data-tab-label and switches tab click handling to setupSyncedTabs(). |
| src/mdx/CodeTabs.astro | Adds data-tab-label and switches tab click handling to setupSyncedTabs(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const updateDialectQueryParam = (dialect: string) => { | ||
| const url = new URL(window.location.href); | ||
| url.searchParams.set(dialectParam, dialect); | ||
| window.history.replaceState({}, "", `${url.pathname}${url.search}${url.hash}`); |
Comment on lines
+247
to
+253
| const matchingButton = Array.from(parent.children).find((child) => { | ||
| return getTabButtonDialect(child as HTMLElement) === dialect; | ||
| }) as HTMLElement | undefined; | ||
|
|
||
| if (matchingButton) { | ||
| activateTabButton(matchingButton); | ||
| tabGroups.add(parent); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds shared state for dialect tabs in the docs.
When a user selects a dialect tab such as
SQLite,MySQL, orPostgreSQL, matching dialect tabs on the same page now switch to the same option. The selected dialect is also reflected in the URL query param, for example?dialect=sqlite, so loading the page with that query preselects matching tabs.Fixes drizzle-team/drizzle-orm#4963
Changes
src/utils-client.tsTabs.astroandCodeTabs.astroto use the shared helperschema.ts,index.ts, or package manager tabs do not sync accidentallyVerification
pnpm run buildpassed/docs/indexes-constraints?dialect=sqliteMySQLupdates matching tab groups and changes the URL to?dialect=mysqlDemo
demo.mp4
Attached a short video showing dialect tabs syncing across the page.